package com.shujia.mr.hw.home4;

import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;
import java.util.ArrayList;

public class MyHome4Reduce extends Reducer<Text,Text,Text,Text> {
    @Override
    protected void reduce(Text key, Iterable<Text> values, Reducer<Text, Text, Text, Text>.Context context) throws IOException, InterruptedException {

        ArrayList<Text> emps = new ArrayList<>();
        for (Text value : values) {
            emps.add(new Text(value.toString()));
        }

        if(emps.size() > 3){
            for (Text emp : emps) {
                context.write(key,emp);
            }
        }

    }
}
